//
//  HWNewSignInViewController.m
//  HWanGame
//
//  Created by 陈道斌 on 2021/1/12.
//  Copyright © 2021 Chendaobin. All rights reserved.
//

#import "HWNewSignInViewController.h"
#import "WMUtil.h"
#import "HWQianDaoModel.h"
#import "HWhuodongguizeView.h"
#import "HWkaiTongChaojijikaView.h"
#import "HWkaiTongChaojijikaView.h"
#import "HWbuqiantakuanView.h"


@interface HWNewSignInViewController ()<UITableViewDelegate,UITableViewDataSource,HWhuodongguizeViewDelegte,HWbuqiantakuanViewDelegate>
@property(strong,nonatomic)UITableView *mainaTableVie;
@property(strong,nonatomic) UIView *headetableView;
@property(strong,nonatomic) UIView *husibeijingView;
@property(strong,nonatomic) UILabel *huodongguiZelabel;


@property(strong,nonatomic) UIImageView *yuanhuImageView;
@property(strong,nonatomic) UILabel *jingELabel;
@property(strong,nonatomic) UILabel *title1Label;
@property(strong,nonatomic) UILabel *ttitle2Label;


@property(strong,nonatomic)NSDictionary *dataDic;
@property(strong,nonatomic) NSMutableArray *dataArr;
@property(strong,nonatomic) NSDictionary *myDic;
@property(strong,nonatomic) NSDictionary *topDic;

@property(strong,nonatomic)UIView *zuixiamianbaiseView; // 最下面白色UIView

@property(strong,nonatomic)UIView *huodejifenView;  // 积分和连续天数
@property(strong,nonatomic)UILabel *jifenxiangqingLabel;
@property(strong,nonatomic)UILabel *qiandaocishLabel;

@property(strong,nonatomic)UIView *riliView;
@property(strong,nonatomic)UILabel *riliLabel;

@property(strong,nonatomic) UIButton *lijiqianBut;

@property(strong,nonatomic)UIImageView *shifouyouImageView;




@end

@implementation HWNewSignInViewController


-(UITableView *)mainaTableVie {

    if  (_mainaTableVie == nil) {

      //   _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, -StatusBarHeight, kScreenW, kScreenH-TabBarHeight) style:UITableViewStylePlain];
        
        _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH) style:UITableViewStylePlain];
        _mainaTableVie.delegate = self;
        _mainaTableVie.dataSource = self;
        _mainaTableVie.separatorStyle = UITableViewCellSeparatorStyleNone;
        _mainaTableVie.backgroundColor = [UIColor whiteColor];
        _mainaTableVie.backgroundColor =  RGB(247, 247, 247);
    }
    return   _mainaTableVie ;

}



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setupUI];
    
    [self addheadeView];
    //
    [self addhuisekongjiaView];
    // 发送请求
   //  [self fasongwangluoqingqiu];
    
}

-(void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    [self fasongwangluoqingqiu];
    
    self.navigationController.navigationBarHidden = NO;
    
}



- (void)fasongwangluoqingqiu  {
    
           NSString *userID = [HWLocallyStoredData getLoginUserID];
            NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
            NSString *sign = [NSString stringWithFormat:@"%@%@%@",userID,tStr,@"fsd213ewdsadqwe2121213edsad"];
            NSString *signMD5 = [WMUtil md5HexDigest:sign];
            NSDictionary *parametes = @{
                                     
                                       @"ios" : @"1",
                                       @"uid":userID,
                                       @"t":tStr,
                                       @"sign":signMD5,
                                      @"member_id":[HWLocallyStoredData getCode],
                                       @"language":[HWjianzhiduiObject returnLanguageAcquisition],
                                       
                                      
                                       };
      
      
           
       //    [MBProgressHUD show:@"正在绑定邮箱"];
           
           [HWWebUtils do4GetWithParameters:parametes hiddenparameterStr:HW_my_sign  progress:nil success:^(id response) {
               
             
               NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
            //   [MBProgressHUD hideHUD];
               
               
               if ([codeStr intValue] == 1) {
                   
                   
                  //  self.dataArr = response[@"data"];
                   
                   
                 self.dataArr =     [HWQianDaoModel mj_objectArrayWithKeyValuesArray:response[@"data"][@"list"]];
                   
                   
                   self.myDic =   response[@"my"];
                   self.topDic = response[@"top"];
                   self.dataDic = response;
                   
                   // 刷新数据
                   [self shuxingshujuUI];
                   
            
               } else {
                
                    [MBProgressHUD  showSuccess:response[@"message"]];
                   
               }
               NSLog(@"%@",response);
               
               
           } failure:^(NSString *error) {

               [MBProgressHUD  showError:@"查询失败"];
               
              
           }];
    
    
    
    
}

// 刷新数据
- (void)shuxingshujuUI  {
    
    
    
     
    
    self.title1Label.text =  [NSString stringWithFormat:@"%@",self.topDic[@"title1"]];
    self.ttitle2Label.text =   [NSString stringWithFormat:@"%@",self.topDic[@"title2"]];
    self.jingELabel.text =   [NSString stringWithFormat:@"￥%@",self.topDic[@"money"]];
    
    
    // charge_points
    
    if ([[NSString stringWithFormat:@"%@",self.topDic[@"money"]] isEqualToString:@"0"]) {
        self.shifouyouImageView.hidden = NO;
        
    }
    
    NSString *jifen =  [HWjianzhiduiObject keylocalization:@"积分"];
    
   //  NSString *str1 = [NSString stringWithFormat:@"%@积分",self.myDic[@"charge_points"]];
    
    NSString *str1 = [NSString stringWithFormat:@"%@%@",self.myDic[@"charge_points"],jifen];
    
    
    
    self.jifenxiangqingLabel.attributedText = [WMUtil attributedStringWithText:str1 withRangText:self.myDic[@"charge_points"] withColor:RGB(248, 119, 6) withFont:[UIFont systemFontOfSize:36]];
    
    
  //   self.jifenxiangqingLabel.text = [NSString stringWithFormat:@"%@",self.myDic[@"charge_points"]];
 //     NSString *str2 = [NSString stringWithFormat:@"连续签到天数%@天",self.myDic[@"serial"]];
    
    NSString *str2 = [NSString stringWithFormat:@"%@%@%@",[HWjianzhiduiObject keylocalization:@"连续签到天数"],self.myDic[@"serial"],[HWjianzhiduiObject keylocalization:@"天"]];
    
    
     self.qiandaocishLabel.attributedText =  [WMUtil attributedStringWithText:str2 withRangText:[NSString stringWithFormat:@"%@",self.myDic[@"serial"]] withColor:RGB(248, 119, 6) withFont:[UIFont systemFontOfSize:12]];
    
    
     NSString *riqistr2 = [NSString stringWithFormat:@"%@月/%@",self.dataDic[@"month"],self.dataDic[@"year"]];

    self.riliLabel.attributedText =  [WMUtil attributedStringWithText:riqistr2 withRangText:[NSString stringWithFormat:@"%@月",self.dataDic[@"month"]] withColor:RGB(51, 51, 51) withFont:[UIFont systemFontOfSize:22]];
    
    
    
    for (int i = 0 ; i < self.riliView.subviews.count; i++) {
        UIView *view = self.riliView.subviews[i];
        if (view.tag == 100) {
            
        } else {
            
            [view removeFromSuperview];
            
        }
        
    }
    
    CGFloat jianju = ((kScreenW - 40)-7*38)/8;
    
    for (int i = 0 ; i < self.dataArr.count ; i++) {
        
            int row = i/7;
            int line = i%7;
        
            UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(jianju+jianju*line+line*38, 50+4+row*5+row*48, 38, 48)];
                   //     nameLabel.text = fanlilistArr[i];
            nameLabel.textAlignment = NSTextAlignmentCenter;
            nameLabel.font = [UIFont systemFontOfSize:10];
            nameLabel.textColor = RGB(51, 51, 49);
            nameLabel.numberOfLines = 2;
        nameLabel.tag = i;
            nameLabel.textColor = [UIColor whiteColor];
           nameLabel.backgroundColor =  RGB(248, 119, 6);
           nameLabel.layer.cornerRadius = 10;
           nameLabel.layer.masksToBounds = YES;
        nameLabel.userInteractionEnabled = YES;
         //   nameLabel.text =@"19\n已签到";
           [self.riliView addSubview:nameLabel];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(nametap:)];
        [nameLabel addGestureRecognizer:tap];
        
        
        
         HWQianDaoModel *model  =  self.dataArr[i];
        NSString  *sign = [NSString stringWithFormat:@"%@",model.sign];
        NSString  *t = [NSString stringWithFormat:@"%@",model.t];
       //     [self setLineSpace:8.0f withText:@"19\n已签到" inLabel:nameLabel];
        if ([sign isEqualToString:@"0"]) {
              

            NSString *timeStr = model.time;
            
            //  NSDate
              
              
              NSDate *xuanzhongRiQi =  [WMUtil dateFromString:timeStr];
              BOOL  panduan=   [WMUtil compareDate:[NSDate date] withDate:xuanzhongRiQi];
              
              if (panduan) {
                  
                  NSLog(@"1");
                 //  [MBProgressHUD showError:@"时间还没有到不能签到"];
                  
                  
                  NSString *str = [NSString stringWithFormat:@"%@\n   ",t];
                        [self setLineSpace:8.0f withText:str inLabel:nameLabel];
                         nameLabel.backgroundColor =  RGB(247, 247, 247);
                         nameLabel.textColor = RGB(51 , 51, 51);
                  
                  
              } else {
                  
                  
                 NSString *weiqiandao = [HWjianzhiduiObject keylocalization:@"未签到"];
                  
                  
               //    NSString *str = [NSString stringWithFormat:@"%@\n未签到",t];
                  
                  NSString *str = [NSString stringWithFormat:@"%@\n%@",t,weiqiandao];
                  
                   [self setLineSpace:8.0f withText:str inLabel:nameLabel];
                    nameLabel.backgroundColor =  RGB(247, 247, 247);
                   nameLabel.textColor = RGB(51 , 51, 51);
              }
            
            
            
     
            
            
        } else {
            
            NSString *weiqiandao = [HWjianzhiduiObject keylocalization:@"已签到"];
            //  NSString *str = [NSString stringWithFormat:@"%@\n已签到",t];
            NSString *str = [NSString stringWithFormat:@"%@\n%@",t,weiqiandao];
             nameLabel.backgroundColor =  RGB(248, 119, 6);
            nameLabel.textColor = RGB(255, 255, 255);
             [self setLineSpace:8.0f withText:str inLabel:nameLabel];
            
        }
           // [self setLineSpace:8.0f withText:@"19\n已签到" inLabel:nameLabel];
        
        
    
     }
    
    int    row =  (int)(self.dataArr.count-1)/7;
    
   //    50+4+row*5+row*48
    
    self.riliView.frame = CGRectMake(20, 100, kScreenW-40, 50+4+row*5+row*48+48+10);
    self.lijiqianBut.frame = CGRectMake(20, self.riliView.bottom+20  , kScreenW-40, 44);
    
    
    
    
    
    
      
    
    
    
}

-(void)setLineSpace:(CGFloat)lineSpace withText:(NSString *)text inLabel:(UILabel *)label{
    if (!text || !label) {
        return;
    }
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.lineSpacing = lineSpace;  //设置行间距
    paragraphStyle.lineBreakMode = label.lineBreakMode;
    paragraphStyle.alignment = label.textAlignment;
    
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [text length])];
    label.attributedText = attributedString;
}




- (void)setupUI {
    
    self.navigationItem.title = @"每日签到";
    self.view.backgroundColor = [UIColor redColor];
    self.navigationItem.title = [HWjianzhiduiObject keylocalization:@"每日签到"];
    
    
    [self.view addSubview:self.mainaTableVie];
    
}


//添加headeView
- (void)addheadeView  {
    
    self.headetableView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH+50)];
    self.mainaTableVie.tableHeaderView =  self.headetableView;
    
    
    
    
}


- (void)addhuisekongjiaView {
    
    self.husibeijingView = [[UIView alloc]initWithFrame:CGRectMake(20, 10, kScreenW-40, 176)];
    self.husibeijingView.backgroundColor = RGB(32, 32, 42);
    self.husibeijingView.layer.cornerRadius = 15;
    self.husibeijingView.layer.masksToBounds = YES;
    self.husibeijingView.userInteractionEnabled = YES;
    [self.headetableView addSubview:self.husibeijingView];
    
    UILabel *huodongguiZelabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW-40 -60 , 22, 70, 18)];
         huodongguiZelabel.font = [UIFont systemFontOfSize:10];
         huodongguiZelabel.textColor = RGB(255, 255, 255);
          huodongguiZelabel.text = @"活动规则";
       huodongguiZelabel.text = [HWjianzhiduiObject keylocalization:@"活动规则"];
    
         huodongguiZelabel.textAlignment = NSTextAlignmentCenter;
         huodongguiZelabel.backgroundColor =  RGB(248, 119, 6);
    
    huodongguiZelabel.layer.cornerRadius = 8;
    huodongguiZelabel.layer.masksToBounds = YES;
     self.huodongguiZelabel = huodongguiZelabel;
    huodongguiZelabel.userInteractionEnabled =YES;
    [self.husibeijingView addSubview:self.huodongguiZelabel];
    
    UITapGestureRecognizer *taptap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(huodongguiji)];
    [huodongguiZelabel addGestureRecognizer:taptap1];
    
    
    
    // demo123456
    
   //  huodongguiZelabel
    
    
    self.yuanhuImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.husibeijingView.bottom-30, kScreenW, 47)];
    self.yuanhuImageView.image = [UIImage imageNamed:@"quxianbeijing"];
   //  self.yuanhuImageView.backgroundColor = [UIColor yellowColor];
    [self.headetableView addSubview:self.yuanhuImageView];
    
    
    
    
    
    UIImageView *meiriqiandaoimage = [[UIImageView alloc]initWithFrame:CGRectMake((kScreenW-40-187)/2, 25, 187, 19)];
    meiriqiandaoimage.image = [UIImage imageNamed:@"meiriqiqnadaoico"];
    [self.husibeijingView addSubview:meiriqiandaoimage];
    
    
    
    
    
    
    
    self.yuanhuImageView = [[UIImageView alloc]initWithFrame:CGRectMake((kScreenW-40-140)/2, meiriqiandaoimage.bottom+8, 140, 72)];
    self.yuanhuImageView.image = [UIImage imageNamed:@"daijingquanico"];
  //   self.yuanhuImageView.hidden = YES;
    [self.husibeijingView addSubview:self.yuanhuImageView];
    
    
    
    self.shifouyouImageView = [[UIImageView alloc]initWithFrame:CGRectMake((kScreenW-40-142)/2, meiriqiandaoimage.bottom, 142, 96)];
    
    self.shifouyouImageView.image = [UIImage imageNamed:@"daijingquanbeijingtup"];
    self.shifouyouImageView.backgroundColor =RGB(32, 32, 42);
    self.shifouyouImageView .hidden = YES;
    [self.husibeijingView addSubview:self.shifouyouImageView];
    
    
    
    
       UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 6, 140, 37)];
       label.font = [UIFont systemFontOfSize:17];
       label.textColor = RGB(255, 255, 255);
        label.text = @"￥10";
       label.textAlignment = NSTextAlignmentCenter;
       label.backgroundColor = [UIColor clearColor];
    self.jingELabel = label;
       [self.yuanhuImageView  addSubview:label];
    
    
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(0, label.bottom+5, 140, 17)];
    label1.font = [UIFont systemFontOfSize:12];
    label1.textColor = RGB(255, 255, 255);
     label1.text = @"无门槛代金券";
    label1.textAlignment = NSTextAlignmentCenter;
    label1.backgroundColor = [UIColor clearColor];
    self.title1Label = label1;
    [self.yuanhuImageView  addSubview:label1];
    
    
    
      UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(20, self.yuanhuImageView.bottom+8, kScreenW-40-20*2, 26)];
      label3.font = [UIFont systemFontOfSize:12];
      label3.textColor = RGB(255, 255, 255);
       label3.text = @"连续签到两周，可获得10元无门槛游戏充值代金券";
      label3.textAlignment = NSTextAlignmentCenter;
      label3.backgroundColor =  RGB(83, 83, 94);
      label3.layer.cornerRadius = 13;
      label3.layer.masksToBounds = YES;
      self.ttitle2Label = label3;
    
      [self.husibeijingView  addSubview:label3];
    
    
    
    self.zuixiamianbaiseView = [[UIView alloc]initWithFrame:CGRectMake(0,  self.husibeijingView.bottom+17, kScreenW, 1000)];
    self.zuixiamianbaiseView.backgroundColor = RGB(255, 255, 255);
  //   self.zuixiamianbaiseView.backgroundColor  = [UIColor redColor];
    [self.headetableView addSubview:self.zuixiamianbaiseView];
    

    //添加里面控件 huodejifenView
    [self addhuisedeView];
    
    
    
    [self addriliview];
    
    
    
    
    
}


// 添加主要控件
- (void)addhuisedeView {
    
    self.huodejifenView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 100)];
    self.huodejifenView.backgroundColor = [UIColor whiteColor];
    [self.zuixiamianbaiseView addSubview:self.huodejifenView];
    
    
         UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(44, 1, 140, 17)];
          label.font = [UIFont systemFontOfSize:13];
          label.textColor = RGB(136, 136, 136);
           label.text = @"已获得积分";
          label.text = [HWjianzhiduiObject keylocalization:@"已获得积分"];
    
          label.textAlignment = NSTextAlignmentLeft;
          label.backgroundColor = [UIColor clearColor];
      
          [self.huodejifenView  addSubview:label];
    
    
            UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW-44-130, 1, 130, 26)];
             label1.font = [UIFont systemFontOfSize:13];
             label1.textColor = RGB(136, 136, 136);
              label1.text = @"连续签到天数 2 天";
             label1.textAlignment = NSTextAlignmentCenter;
             label1.backgroundColor = RGB(241, 241, 241);
             label1.layer.cornerRadius = 13;
            label1.layer.masksToBounds = YES;
             self.qiandaocishLabel = label1;
             [self.huodejifenView  addSubview:label1];
    
    
    
            UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(44, 19, 260, 62)];
               label3.font = [UIFont systemFontOfSize:16];
              label3.textColor = RGB(248, 119, 6);
               label3.text = @"10 积分";
              label3.textAlignment = NSTextAlignmentLeft;
            //   label3.backgroundColor = RGB(241, 241, 241);
              label3.layer.cornerRadius = 13;
             label3.layer.masksToBounds = YES;
            self.jifenxiangqingLabel = label3;
            [self.huodejifenView  addSubview:label3];
     
    
    
    
    
    
    
    
    
    
    
}


// 添加UIview
- (void)addriliview  {
    
    self.riliView = [[UIView alloc]initWithFrame:CGRectMake(20, 100, kScreenW-40, 320 )];
    self.riliView.backgroundColor = RGB(247, 247, 247);
    self.riliView.layer.cornerRadius = 10;
    self.riliView.layer.masksToBounds = YES;
    [self.zuixiamianbaiseView addSubview:self.riliView];
    
    
    
    

       UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(24, 15, 180, 30)];
        label.font = [UIFont systemFontOfSize:14];
        label.textColor = RGB(51, 51, 51);
         label.text = @"08月/2020";
        label.textAlignment = NSTextAlignmentLeft;
        label.backgroundColor = [UIColor clearColor];
       label.tag = 100;
    
        [self.riliView  addSubview:label];
       self.riliLabel = label;
    
    
    
    UIButton *fanhuiBut = [UIButton buttonWithType:UIButtonTypeCustom];
       fanhuiBut.frame = CGRectMake(20, self.riliView.bottom+20  , kScreenW-40, 44);
       fanhuiBut.backgroundColor =  RGB(246, 106, 5);
     //   [fanhuiBut setImage:[UIImage imageNamed:@"fanhuijiemianIco"] forState:UIControlStateNormal];
       [fanhuiBut setTitle:@"立即签到" forState:UIControlStateNormal];
       [fanhuiBut setTitle:[HWjianzhiduiObject keylocalization:@"立即签到"] forState:UIControlStateNormal];
      [fanhuiBut setTitleColor:RGB(255, 255, 255) forState:UIControlStateNormal];
    
       [fanhuiBut addTarget:self action:@selector(fanhuiButTap) forControlEvents:UIControlEventTouchUpInside];
    fanhuiBut.layer.cornerRadius = 22;
    fanhuiBut.layer.masksToBounds = YES;
    [self.zuixiamianbaiseView addSubview:fanhuiBut];
    
     
    self.lijiqianBut = fanhuiBut;
    
    
}


// 立即签到
- (void)fanhuiButTap {
    
    NSString *uidStr = [NSString stringWithFormat:@"%@",[HWLocallyStoredData getLoginUserID]];
        NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
        NSString *signStr = [NSString stringWithFormat:@"%@%@%@",uidStr,tStr,@"fsd213ewdsadqwe2121213edsad"];
         NSString  *signStrMd5  =   [WMUtil md5HexDigest:signStr];
        
        
               DLog(@"MD5 ：%@",signStrMd5);
        
          NSDictionary *parametes = @{
                                                @"ios" : @"1",
                                                @"ct"  : @"app",
                                                @"ac" : @"sign",
                                                @"t" : tStr,
                                                @"sign" :signStrMd5,
                                                @"uid" :uidStr
        
                                               };
      
      
        
        
    //     self.dataMutaArr = [[NSMutableArray alloc]init];
        
        
        [MBProgressHUD show:@"正在签到...."];
        [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
        

           NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
               if ([codeStr intValue] == 1) {
              
                  [MBProgressHUD showError:response[@"message"]];
                  //  [self  chaxuanqiandao];
                   [self fasongwangluoqingqiu];
                   
                   
                   
                   
              
                } else {
        
                    [MBProgressHUD showError:response[@"message"]];
        
                }
        
        
        
          } failure:^(NSString *error) {
                // [SVProgressHUD dismiss];
        
                        [MBProgressHUD showSuccess:@"查询失败"];
                //  [MBProgressHUD hideHUD];
        
        
         }];
    
    
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    
    
    return 0;
    
    
}

 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *cellID = @"cellID";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    if (!cell) {
        
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        
        
    }
    
    
    
    
    return  cell;
    
    
    
    
}
 







#pragma mark ------ 添加控件

- (void)nametap:(UITapGestureRecognizer *)sender {
    UIView  *view1  = sender.view;
    
    HWQianDaoModel *model =  self.dataArr [view1.tag];
    
    
    NSString *timeStr = model.time;
    
    //  NSDate
      
      
      NSDate *xuanzhongRiQi =  [WMUtil dateFromString:timeStr];
      BOOL  panduan=   [WMUtil compareDate:[NSDate date] withDate:xuanzhongRiQi];
      
      if (panduan) {
          
          NSLog(@"1");
          [MBProgressHUD showError:@"时间还没有到不能签到"];
          
          
      } else {
          // timeStr 时间小
          // NSLog(@"2");
           
         // isDateInToday
     //    [xuanzhongRiQi isEqualToDate:<#(nonnull NSDate *)#>]
          
          BOOL   jingtian =   [WMUtil   checkTheDate:timeStr];
          
          if (jingtian) {
              
              NSLog(@"今天");
             //  [self lijiqinadaoLabeltap];
              [self fanhuiButTap];
              
              
          } else {
              
               NSLog(@"前天");
              
              NSString * huiyuan = [NSString stringWithFormat:@"%@",self.myDic[@"huiyuan"]];
              if ([huiyuan isEqualToString:@"0"]) {
                  
                 //  HWkaiTongChaojijikaView *
                  
                  HWkaiTongChaojijikaView *xiaohaoview = [[HWkaiTongChaojijikaView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
                
                  [kKeyWindow addSubview:xiaohaoview];
                  
                  return;
                   
                  
                  
              }
              
              
              
               if ([model.sign isEqualToString:@"0"]) {
                  
                } else {
                  
                     [MBProgressHUD showError:@"你已经签到了"];
                                  return;
                  
                }
              
              
        
              
              
              NSString * bu_num = [NSString stringWithFormat:@"%@",self.myDic[@"bu_num"]];
              
              if ([bu_num isEqualToString:@"0"]) {
                  
                  
                  [MBProgressHUD showError:@"补签次数已上限"];
                  return;
    
              }
               
              
              HWbuqiantakuanView *xiaohaoview = [[HWbuqiantakuanView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
               xiaohaoview.model = model;
              xiaohaoview.huiyuaStr = huiyuan;
              xiaohaoview.cishuStr =bu_num;
              xiaohaoview.delgate = self; 
                [kKeyWindow addSubview:xiaohaoview];
              [xiaohaoview shuaxingshuju];
              
            
                
                return ;
                
                
              
              
              NSString *ziStr = [timeStr stringByReplacingOccurrencesOfString:@"-" withString:@""];
             //  [self retroactiveqindao];
              NSLog(@"取代哦  %@",ziStr);
              [self retroactiveqindao:ziStr];

          }
          
          
          
      }
    
    
}


// 判断是否是会员


 


//补签
- (void)retroactiveqindao:(NSString *)time {
    
    
    
    
    

    
    
    
        NSString *uidStr = [NSString stringWithFormat:@"%@",[HWLocallyStoredData getLoginUserID]];
        NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
        NSString *signStr = [NSString stringWithFormat:@"%@%@%@",uidStr,tStr,@"fsd213ewdsadqwe2121213edsad"];
        NSString  *signStrMd5  =   [WMUtil md5HexDigest:signStr];
        
        
               DLog(@"MD5 ：%@",signStrMd5);
        
          NSDictionary *parametes = @{
                                                @"ios" : @"1",
                                                @"ct"  : @"app",
                                                @"ac" : @"bu_sign",
                                                @"t" : tStr,
                                                @"sign" :signStrMd5,
                                                @"uid" :uidStr,
                                                @"date" : time
                                                
                                               };
      
      
        
        
    //     self.dataMutaArr = [[NSMutableArray alloc]init];
        
        
        [MBProgressHUD show:@"正在补签到...."];
        [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
        

           NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
               if ([codeStr intValue] == 1) {
              
                   [MBProgressHUD showError:response[@"message"]];
                 //   [self  chaxuanqiandao];
                   
                   [self fasongwangluoqingqiu];
                   
                   
                   
              
                } else {
        
                    [MBProgressHUD showError:response[@"message"]];
        
                }
        
        
        
          } failure:^(NSString *error) {
                // [SVProgressHUD dismiss];
        
                 [MBProgressHUD showSuccess:@"不签失败"];
                //  [MBProgressHUD hideHUD];
        
        
         }];
    
    
    
    
    
    
    
    
}


- (void)huodongguiji {
    
    
     HWhuodongguizeView *xiaohaoview = [[HWhuodongguizeView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
     xiaohaoview.delegate = self;
     [kKeyWindow addSubview:xiaohaoview];
    
    [xiaohaoview shuxingshuju];
    
    
    
    
    
    
     
}


- (void)dianjiqiandao {
    
    [self fanhuiButTap];
    
    
}


- (void)zhishibuqian:(HWQianDaoModel *)mdel {
    
     NSString *timeStr = mdel.time;
    NSString *ziStr = [timeStr stringByReplacingOccurrencesOfString:@"-" withString:@""];
    //  [self retroactiveqindao];
     NSLog(@"取代哦  %@",ziStr);
     [self retroactiveqindao:ziStr];
    
    
}


@end
